package com.itheima.Demo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

public class Demo02ListMap {
    public static void main(String[] args) {
        //罗志祥-蝴蝶    陈羽凡-白百何     文章-姚笛
        HashMap<String,String> map1 = new HashMap<>();
        //添加
        map1.put("罗志祥","蝴蝶");
        map1.put("陈羽凡","白百何");
        map1.put("文章","姚笛");
        //令狐冲-小尼姑  张无忌-赵敏       郭靖-黄蓉
        HashMap<String,String> map2 = new HashMap<>();
        map2.put("令狐冲","小尼姑");
        map2.put("张无忌","赵敏");
        map2.put("郭靖","黄蓉");
        //要把所有人放在一起
        //创建一个新集合,里面存放两组hashmap集合;
        ArrayList<HashMap<String,String> > list = new ArrayList<>();
        //添加hashmap集合进入Arraylist集合;
        list.add(map1);
        list.add(map2);
        //遍历list集合
        for (HashMap<String, String> map : list) {
            //遍历list集合取出set集合;
            Set<String> s1 = map.keySet();
            //遍历set集合
            for (String s : s1) {
                //获取键位值
                String s2 = map.get(s);
                //通过键位值获取value;
                System.out.println(s+"="+s2);
            }
            System.out.println("=================");
        }

    }
}
